package com.market.model;

import java.math.BigDecimal;

/**
 * 水果类
 */
public class Fruit {
    private final String name; // 水果名称
    private final BigDecimal price; // 水果单价
    private int quantity; // 水果数量
    private BigDecimal discount;// 打折数量

    public Fruit(String name, BigDecimal price, int quantity) {
        this.name = name;
        this.price = price;
        this.quantity = quantity;
    }

    public Fruit(String name, BigDecimal price, int quantity, BigDecimal discount) {
        this.name = name;
        this.price = price;
        this.quantity = quantity;
        this.discount = discount;
    }

    // 计算水果总价
    public BigDecimal getTotalPrice() {
        return price.multiply(new BigDecimal(quantity));
    }

    // 计算打折后的价格
    public BigDecimal getDiscountPrice() {
        return price.multiply(new BigDecimal(quantity)).multiply(discount);
    }

    public String getName() {
        return name;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public BigDecimal getDiscount() {
        return discount;
    }
}